package com.jpdr.wificommdev;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class IntroActivity extends Activity {
	
	TextView textView_Intro_Version;
	View viewRoot;
	int color_App_Background;
	boolean bool_Show_Intro;
	Context contextIntroActivity;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_intro);

		contextIntroActivity = this.getApplicationContext();
		
		bool_Show_Intro = this.getResources().getBoolean(R.bool.show_intro);
		
		if (bool_Show_Intro){
		
			textView_Intro_Version = (TextView) this.findViewById(R.id.textView_Intro_Version);
			try {
				textView_Intro_Version.setText("v" + this.getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
			} catch (NameNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
	
			viewRoot = textView_Intro_Version.getRootView();
			color_App_Background = this.getResources().getColor(R.color.app_background);
			viewRoot.setBackgroundColor(color_App_Background);
		
			new TimeoutOperation().execute("");
	
			
		}
			
	}
	
	
	private class TimeoutOperation extends AsyncTask<String, Void, Void>{

	    @Override
	    protected Void doInBackground(String... params) {

	        try {
	            Thread.sleep(5000);
	        } catch (InterruptedException e) {
	            e.printStackTrace();
	        }
	        return null;
	    }

	    @Override
	    protected void onPostExecute(Void result) {
	    	Intent intentMainActivity;
			//intentMainActivity = new Intent(contextIntroActivity, MainActivity.class);
			intentMainActivity = new Intent(contextIntroActivity, MenuActivity.class);
	        startActivity(intentMainActivity);
	    }
	}
		

}
